import { http } from "@/utils/http";
import type { AjaxResult } from "./types";
import { baseUrlApi } from "./utils";
// 分页查询订单
export const listSaleByPage = (params: QueryParams) => {
  return http.request<AjaxResult>("get", baseUrlApi("/sale/page"), { params });
};

// 新增支付

export const addPayment = (data: PaymentForm) => {
  return http.request<AjaxResult>("post", baseUrlApi("/sale/addPayment"), {
    data
  });
};

interface QueryParams {
  pageNum: number;
  pageSize: number;
  saleId?: number;
  saleNo?: string;
  status?: string;
}

interface PaymentDTO {
  paymentId: number;
  paymentNo: string;
  payMethod: string;
}

interface SaleDTO {
  saleId: number;
  saleNo: string;
  total: number;
  status: string;
  payment: PaymentDTO;
}

interface SaleInfo {
  saleId: number;
  saleNo: string;
  total: number;
  status: string;
}

interface PaymentForm {
  saleId: number;
  payMethod: string;
  amount: number;
}

export type { SaleDTO, SaleInfo, QueryParams, PaymentForm };
